package com.iss.airsys.service;

import com.iss.airsys.dao.RoomfreeDao;
import com.iss.airsys.entity.Room;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RoomfreeService {
    @Autowired
    RoomfreeDao roomfreeDao;
    public boolean insertRoom(Room room){
        Integer count = roomfreeDao.insertRoom(room);
        if (count>0){
            return true;
        }else
            return false;
    }
    public boolean deleteRoom(String[]room_ids){
        Integer count = roomfreeDao.deletRoom(room_ids);
        if (count>0){
            return true;
        }else
            return false;
    }
    public boolean updatetRoom(Room room){
        Integer count= roomfreeDao.updateRoom(room);
        if (count>0){
            return true;
        }else
            return false;

    }
    public Room selectRoomByid(String room_id){
        return roomfreeDao.selectRoom(room_id);
    }


    public List<Room> selectAll(Double priceFrom,Double priceTo){
        List<Room>room  = roomfreeDao.selectAll(priceFrom,priceTo);

            return room;

    }

    public List<String>selectRoomid(){
       return roomfreeDao.selectRoomid();

    }

    public Integer updateRoomState(@Param("room_state") String room_state,@Param("room_id") String room_id){
        return roomfreeDao.updateRoomState(room_state,room_id);
    }

    public String selectRoomState(@Param("room_id")String room_id){
        return roomfreeDao.selectRoomState(room_id);
    }


    public Integer CheckoutRoom(Integer[] Checkout_room){
        return roomfreeDao.CheckoutRoom(Checkout_room);
    }
}
